package com.zyd.blog.homeart.enums;

public enum SpecCode {
    // 网路状态
    NET_OK(200,"通畅"),
    NET_Forbidden ( 403,"禁止"),
    METHOD_NOT_ALLOWED ( 405,"方法不被允许"),
    UNSUPPORTED_MEDIA_TYPE ( 415,"不识别的媒体格式"),
    INTERNAL_SERVER_ERROR( 500,"内部错误"),
    NET_Moved(301,"重定向"),
    NET_Found(302,"新址重定向"),
    BAD_REQUEST(400,"请求无效"),
    //用户
    VALIDATE_ERROR(1000,"输入项不满足要求"),
    SQL_ERROR(1001,"数据库不可用");

    // 成员变量
    private int code;
    private String msg;
    // 构造方法
    SpecCode(int code, String msg) {
        this.msg = msg;
        this.code = code;
    }

    // 普通方法
    public static String getName(int index) {
        for (SpecCode c : SpecCode.values()) {
            if (c.getCode() == index) {
                return c.msg;
            }
        }
        return null;
    }

    public String getMsg() {
        return msg;
    }
    public void setMsg(String msg) {
        this.msg = msg;
    }
    public int getCode() {
        return code;
    }
    public void setCode(int code) {
        this.code = code;
    }
    @Override
    public String toString() {
        return this.code +"";
    }
}
